<template>
<div>
  <p-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <p-spin :spinning="confirmLoading">
      <p-form :form="form">
		  <div class="base-info">基本信息</div>
		  <p-row>
			  <p-col  :span="8">
			<p-form-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol">
				{{userInfo.name}}
				<!-- <j-select-user-by-dep :disabled="isQuery" v-decorator="['scientificPlease', validatorRules.scientificPlease]" :trigger-change="true"/> -->
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="部门名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<!-- <p-select
					show-search
					:value="value"
					placeholder="请选择部门名称"
					:default-active-first-option="false"
					:show-arrow="false"
					:filter-option="false"
					:not-found-content="null"
					@search="()=>{}"
					@change="()=>{}"
				>
					<p-select-option v-for="d in tagList" :key="d.value">
					{{ d.label }}
					</p-select-option>
				</p-select> -->
				<!-- <p-popover title="">
					<template slot="content">
					<span >{{userInfo.orgposRemark}}</span>
					</template>
					<span class="dtName">{{userInfo.orgposRemark}}</span>
				</p-popover> -->
				<j-select-depart 
				:disabled="isQuery" 
				:depart="initModel.orgCode" 
				v-decorator="['dptno', validatorRules.dptno]" 
				:trigger-change="true"
				@change="changePart"/>
			</p-form-item>
		  </p-col>
		  </p-row>
        <p-row>
		  <!-- <p-col  :span="8">
			<p-form-item label="任务编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input readOnly :disabled="isQuery" v-decorator="[ 'scientificOrder', validatorRules.scientificOrder]" placeholder="请输入任务编号"></p-input>
			</p-form-item>
		  </p-col> -->
		  
		  <p-col  :span="8">
			<p-form-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery"  v-decorator="[ 'scientificname', validatorRules.scientificname]" placeholder="请输入项目名称"></p-input>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="项目编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery" v-decorator="[ 'scientificno', validatorRules.scientificno]" placeholder="请输入项目编码"></p-input>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="加工类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-dict-select-tag :disabled="isQuery" type="list" v-decorator="['scientificType', validatorRules.scientificType]" :trigger-change="true" dictCode="mes_scientific_type" placeholder="请选择加工类型"/>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="项目经理" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery" v-decorator="[ 'scientificManager', validatorRules.scientificManager]" placeholder="请输入项目名称"></p-input>
			</p-form-item>
		  </p-col>	  
		  <p-col  :span="8">
			<p-form-item label="加工说明" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery" v-decorator="[ 'scientificInstructions', validatorRules.scientificInstructions]" placeholder="请输入项目名称"></p-input>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="联系方式" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery"  v-decorator="[ 'scientificContact', validatorRules.scientificContact]" placeholder="请输入联系方式"></p-input>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="BOMreport" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-upload @change="changeOkUpload" :disabled="isQuery" v-decorator="['bomReport', validatorRules.bomReport]" :trigger-change="true"></j-upload>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="科研bom表" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-upload @change="changeOkUpload1" :disabled="isQuery" v-decorator="['researchBom', validatorRules.researchBom]"  :trigger-change="true"></j-upload>
			</p-form-item>
		  </p-col>
        </p-row>

        <div class="base-info">加工内容</div>
		<p-row>
		  <p-col  :span="8">
			<p-form-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery" v-decorator="[ 'name', validatorRules.name]" placeholder="请输入名称"></p-input>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="型号/图号（版号）" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery" v-decorator="[ 'model', validatorRules.model]" placeholder="请输入型号/图号（版号）"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery"  v-decorator="[ 'quantity', validatorRules.quantity]" placeholder="请输入数量"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="需求完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-date  :disabled="isQuery"  placeholder="请输入需求完成时间" v-decorator="[ 'contentTime', validatorRules.contentTime]" :trigger-change="true" style="width: 100%"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="成本中心" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-input :disabled="isQuery" v-decorator="[ 'costCenter', validatorRules.costCenter]" placeholder="请输入成本中心"></p-input>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="物料齐套时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-date  :disabled="isQuery"  placeholder="请输入物料齐套时间" v-decorator="[ 'scientificQitime', validatorRules.scientificQitime]" :trigger-change="true" style="width: 100%"/>
			</p-form-item>
		  </p-col>

		  <p-col  :span="8">
			<p-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-upload @change="changeOkUpload2" :disabled="isQuery" v-decorator="['accessory', validatorRules.accessory]" :trigger-change="true"></j-upload>
			</p-form-item>
		  </p-col>
		  </p-row>
		   <div v-if="isQuery && model.status===3" > <!--v-if="model.status ===3" -->
		  <div class="base-info">外协厂家范围</div>
              <div class="base-info-supplier" @click="outsoulHandle">
				  {{supplierStr || '暂无数据'}}
			  </div>
		   </div>
		   <!--  -->
		  <div v-if="isQuery && model.status ===2"  class="base-info" >工艺路线维护 
			  <!-- <p style="float:right;cursor:pointer;color:#409EFD;" @click="closeModal">查询</p> -->
		 </div>
		  <mes-mf-route-maintenance v-if="isQuery && model.status ===2"  ref="modalRoute" :scientificId="scientificId"></mes-mf-route-maintenance>

		  <div  v-if="isQuery && model.status===4"> <!--v-if="model.status===4" -->
		  <div class="base-info">采购评审</div>
		  <p-row>
			<p-col :span="8">
			 <div class="base-info-supplier">
				<p-radio-group 
				v-model="radioInfo"
				v-if="plainOptions.length" 
				@change="onHandleChangeRadio">
				<p-radio :value="item" v-for="item in plainOptions" :key="item.label+'raiod'">
					{{item.label}}
				</p-radio>
				</p-radio-group>
				<span v-else>暂无数据</span>
			 </div>
			</p-col>
		   </p-row>
		  </div>

		<div v-if="isQuery && model.status===6">
		  <div class="base-info">事业部确认</div>
		  <p-row>
		  <p-col  :span="8">
			<p-form-item label="实际领用时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-date    placeholder="请输入实际领用时间" v-decorator="[ 'actualStartTime', validatorRules.actualStartTime]" :trigger-change="true" style="width: 100%"/>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="计划完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-date    placeholder="请输入计划完成时间" v-decorator="[ 'scientificCompleteTime', validatorRules.scientificCompleteTime]" :trigger-change="true" style="width: 100%"/>
			</p-form-item>
		  </p-col>
		  <p-col  :span="8">
			<p-form-item label="实际完成时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<j-date    placeholder="请输入实际完成时间" v-decorator="[ 'actualFinishTime', validatorRules.actualFinishTime]" :trigger-change="true" style="width: 100%"/>
			</p-form-item>
		  </p-col>	
		  <p-col  :span="8">
			<p-form-item label="实际完成情况" :labelCol="labelCol" :wrapperCol="wrapperCol">
				<p-select placeholder="请输入实际完成情况" @change="changeCompletion" v-decorator="['actualCompletion', validatorRules.actualCompletion]" >
				<p-select-option v-for="item in tagList" :key="item" :value="item.value">
					{{ item.label }}
				</p-select-option>
				</p-select>
			</p-form-item>
		  </p-col>
		  </p-row>
		  </div>
      </p-form>
    </p-spin>
	<section slot="footer">
		<p-button v-if="isQuery" @click="handleManageBack">回退</p-button>
		<p-button @click="close">取消</p-button>
		<p-button @click="handleOk(1)" type="primary">保存</p-button>
		<p-button type="primary" v-if="!isQuery" @click="handleOk(2)">提交</p-button>  <!--表单提交 -->
		<p-button type="primary" v-if="isQuery" @click="businessConfirm">确认</p-button><!--状态操作提交 -->
	</section>
  </p-modal>

  <p-modal 
  title="选择供应商" 
  @ok="suppliOK" 
  v-model="suppliVisible"
  :width="width"
  :footer="null">
	  <!-- <mes-mf-suggest-list :mainId="this.model.id" /> -->
	  <mes-supplier
	  ref="supplier_mes"
	  @sumitOk="getSupplierOk"
	  @cancel="suppliVisible=false">
	  </mes-supplier>
  </p-modal>
  </div>
</template>

<script>


  import { SubmitOnchangMixin } from '@/mixins/SubmitOnchangMixin'
  import { httpAction, putAction,getAction, api } from '@/api/manage'
  import moment from 'moment'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'
  import JUpload from './JUpload'
  import JSelectDepart from './JSelectDepart'
  import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
  import JDictSelectTag from "@/components/dict/JDictSelectTag"
  import MesMfSuggestList from '../MesMfSuggestList'
  import MesMfRouteMaintenance from './MesMfRouteMaintenance'
  import MesSupplier from './MesSupplier'
import { postAction } from '../../../../../../api/manage'

  export default {
    name: "MesMfScientificModal",
	mixins: [SubmitOnchangMixin],
    components: { 
      JDate,
      JUpload,
      JSelectDepart,
      JSelectUserByDep,
	  JDictSelectTag,
	  MesMfSuggestList,
	  MesSupplier,
	  MesMfRouteMaintenance
    },
    data () {
      return {
        form: this.$form.createForm(this),
        width: 1200,
		visible: false,
		suppliVisible:false,
		isQuery:false,
		supplierStr:'',
		urlDownload:'',
		scientificId:'',
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        scientificOrder:{rules: [{ required: true, message: '请输入任务编号!' }]},
        scientificPlease:{rules: [{ required: true, message: '请输入申请人!' }]},
		dptname:{rules: [{ required: true, message: '请输入部门名称!' }]},
		dptno:{rules: [{ required: true, message: '请输入部门名称!' }]},
        scientificContact:{rules: [{ required: true, message: '请输入联系方式!' }]},
        scientificno:{rules: [{ required: true, message: '请输入项目编码!' }]},
        scientificname:{rules: [{ required: true, message: '请输入项目名称!' }]},
        scientificClassification:{},
        scientificType:{rules: [{ required: true, message: '请输入加工类型!' }]},
		name:{rules: [{ required: true, message: '请输入名称!' }]},
        contentTime:{rules: [{ required: true, message: '请输入需求完成时间!' }]},
        model:{rules: [{ required: true, message: '请输入型号/图号（版号）!' }]},
        scientificStarttime:{rules: [{ required: true, message: '请输入计划开始时间!' }]},
        scientificQitime:{rules: [{ required: true, message: '请输入实际物料齐套时间!' }]},
        scientificState:{rules: [{ required: true, message: '请输入当前状态!' }]},
        bomReport:{},
		researchBom:{},
		costCenter:{rules: [{ required: true, message: '请输入成本中心!' }]},
		quantity:{rules: [{ required: true, message: '请输入数量!' }]},
		scientificInstructions:{rules: [{ required: true, message: '请输入加工说明!' }]},
		scientificManager:{rules: [{ required: true, message: '请输入项目经理!' }]},
        accessory:{},
        supno:{rules: [{ required: true, message: '请输入供应商编码!' }]},
        supname:{rules: [{ required: true, message: '请输入供应商名称!' }]},
        scientificCompleteTime:{},
        actualStartTime:{},
        actualFinishTime:{},
        actualCompletion:{},
		},
		manageBack:'',//回退
		files:{file1:'',file2:'',file3:''},
        url: {
          add: '/mes-manufacture/mfScientific',  //保存
		  edit: '/mes-manufacture/mfScientific/submit', //提交
		  approveSupplier:"/mes-manufacture/mfSuggest/approve",//供应商提交
		  businessConfirm:'/mes-manufacture/mfScientific/business/confirm', //事业部确认
		  supplier:'/mes-manufacture/mfSuggest/',
		//   /mes-manufacture/mfSuggest/back/
		  routestr:'/mes-manufacture/mfProcessRouteMaintenance/approve/',//工艺路线提交
		  procurement:'/mes-manufacture/mfSuggest/purchase/approve', //采购提交
		  savePurchase:'/mes-manufacture/mfSuggest/purchase',//采购保存
		  userList:'/poros-permission/secStaff/list', //用户列表
		  userUid:'/poros-permission/secStaff/getUserByUid/',//uid yonghu
		  addSupplier:'/mes-manufacture/mfSuggest',//新增供应商建议

		},
		tagList:[
		{label:'正常',value:0},
		{label:'滞后',value:1},
		{label:'提前',value:2},
		],
		plainOptions:[],
		radioInfo:{},
		uid:'',
		userInfo:{},
		initModel:{},
		supplierInfo:{},
      }
    },
    created () {
		this.urlDownload = location.origin + "/api/poros-oss/file/download";
	},
	mounted(){
		this.getuserUidList(this.userInfos.uid)
	},
	props:{
		userInfos:{
			type:Object,
			defalut(){
				return {}
			}
		}
	},
	watch:{
      userInfos:{
        handler(newVal,oldVal){
		  this.userInfos = newVal
          this.getuserUidList(this.userInfos.uid)
        },
        deep:true
	  },
    },
    methods: {
		//获取供应商select List
		getSupplierOk(dataList){
			dataList.map(item=>{
				item.mesMfScientificId = this.model.id
			})
			this.supplierInfo={
				mesMfScientificId:this.model.id,
				suggestAddParamList: dataList
			}
           postAction(this.url.addSupplier,this.supplierInfo).then(res=>{
              if(res.code === 0){
				  this.suppliVisible = false
				  this.supplierStr = dataList.map(item=>item.supname).toString()
				  this.$message.success('操作成功')
			  }else{
				  this.$message.success(res.msg)
			  }
		   })
		},
	outsoulHandle(){
	   this.suppliVisible = true
	   this.$refs.supplier_mes.initColums()
	},
		//用户uid
	getuserUidList(uid){
         getAction(this.url.userUid+uid).then(res=>{
			 this.userInfo = res.data || {}
			//  this.form.dptno = this.userInfo.orgposRemark
			// this.userInfo.orgPosDtos[0].orgCode
			this.initModel.orgCode = this.userInfo.orgPosDtos[0].orgCode
			this.initModel.dptno = this.userInfo.orgPosDtos[0].orgName
			this.initModel.dptname = this.userInfo.orgposRemark
		 })
	  },
		changeCompletion(data){
			this.model.actualCompletion = data
			},
      add () {
        this.edit(this.initModel);
        // this.getRuleCodeValue();
	  },
	  changePart(no,name){
		this.model.dptname = name
		this.model.dptno = no
		console.log(this.model)
	  },
      getRuleCodeValue() {
        let param = {
          commonFormData: this.model,
          rules: [
            {"ruleCode": "rwbh", "columnName": "scientificOrder"},
            ]
        }

        putAction(api.ruleBaseURL, param).then(res => {
          // 执行成功，获取返回的值，并赋到页面上
          if (res.success) {
			console.log("生成的编码：" + res.data)
            const item = res.data.scientificOrder? res.data : {scientificOrder:(new Date()).valueOf()};
            this.form.setFieldsValue(pick(item, Object.keys(item)))
          }
        })
      },
      edit (record,isQuery) {
		this.form.resetFields();
		if(isQuery===1){
			this.isQuery = true
		}else{
			this.isQuery = false
		}
		this.confirmLoading = false
		this.model = Object.assign({}, record);
		this.initModel.orgCode = this.model.dptname
		this.scientificId = this.model.id
		if(this.model.id){
			//bomReport回显
		const fileJson = {
			fileName:this.model.reportName,
			filePath:this.urlDownload + "?path=" + this.model.bomReport,
			fileUrl:this.model.bomReport,
		};
		const newFileList = []
		newFileList.push(fileJson);
		this.model.bomReport = JSON.stringify(newFileList)
        //bom科研回显
		const fileJson1 = {
			fileName:this.model.researchName,
			filePath:this.urlDownload + "?path=" + this.model.researchBom,
			fileUrl:this.model.researchBom,
		};
		const newFileList1 = []
		newFileList1.push(fileJson1);
		this.model.researchBom = JSON.stringify(newFileList1)
		//附件回显
		if(this.model.accessoryName){
			const fileJson2 = {
			fileName:this.model.accessoryName,
			filePath:this.urlDownload + "?path=" + this.model.accessory,
			fileUrl:this.model.accessory,
		};
		const newFileList2 = []
		newFileList2.push(fileJson2);
		this.model.accessory = JSON.stringify(newFileList2)
		}
		}
		
	
		this.getSupplierList(this.model.id)
        this.visible = true;
        this.$nextTick(() => {
		  this.form.setFieldsValue(pick(this.model,'scientificOrder','scientificPlease',
		  'dptname','scientificContact','scientificno','scientificname',
		  'scientificClassification','scientificType','name','contentTime','model',
		  'scientificStarttime','scientificQitime','scientificState','bomReport',
		  'researchBom','accessory','supno','supname','scientificCompleteTime',
		  'actualStartTime','actualFinishTime','actualCompletion','costCenter',
		  'scientificManager','dptno','quantity','scientificInstructions',
		  'createTime','updateBy','updateTime'))
		})

      },
      close () {
        this.$emit('close');
        this.visible = false;
	  },
	  closeModal(){
		this.$emit('closeModal',this.model.id);
		this.visible = false;
	  },
	  initFileListArr(val){
        let fileList = [];
        for(var a=0;a<val.length;a++){
          fileList.push({
            uid:uidGenerator(),
            name:val[a].fileName,
            status: 'done',
            url: val[a].filePath,
            response:{
              status:"history",
              message:val[a].filePath
            }
          })
        }
        return fileList  
      },
	  changeOkUpload(data){
		//reportName BOMreport
		//researchName  科研bom
		//accessoryName  附件
		//   if(data){
		// 	const info = JSON.parse(data)
		// 	if(info.length){
		// 		this.model.reportName = info[0].fileName || ''
		// 		this.files.file1=info[0].fileUrl || ''
		// 	}
		//   }
	  },
	  changeOkUpload1(data){
		//   if(data){
		// 	const info = JSON.parse(data)
		// 	if(info.length){
		// 		this.model.researchName = info[0].fileName || ''
		// 		this.files.file2=info[0].fileUrl || ''
		// 	}
		//   }
		//   this.model.researchBom = data[0].response.data
	  },
	  changeOkUpload2(data){
		//   if(data){
		// 	const info = JSON.parse(data)
		// 	if(info.length){
		// 		this.model.accessoryName = info[0].fileName || ''
		// 		this.files.file3=info[0].fileUrl || ''
		// 	}
		//   }
		//   this.model.accessory = data[0].response.data
	  },
	  onHandleChangeRadio(val){
        console.log(this.GroupList)
	  },
	  
	  //供应商建议
	  getSupplierList(id,params){
		  getAction(this.url.supplier+id,params).then(res=>{
			  if(res.code === 0 && res.data){
			   this.supplierStr = res.data.map(item=>item.supname).toString()
			   this.plainOptions = res.data
			   this.plainOptions.map(item=>{
				   item.label = item.supname;
				   item.value = item.supno
			   })
			   this.supplierInfo = {
				 mesMfScientificId:this.model.id,
				 suggestAddParamList:this.plainOptions
			   }
			  }
	    })
	  },
      //保存
	  handleSave(){
		 let that = this
		this.form.validateFields((err, values) => {
			if (!err) {
				that.confirmLoading = true;
				let httpurl = '';
				let method = '';
				console.log(values)
				console.log(this.model)
				// formData.dptname = this.userInfo.orgposRemark //部门
				// formData.dptno = this.userInfo.orgposRemark //部门
				let formData = Object.assign(this.model, values);
				this.formData = Object.assign(this.model, values);
				formData.scientificPlease = this.userInfos.name //申请人
				//编辑触发
				httpurl=this.url.add;
				method = 'post';
				that.modalFrom(httpurl,formData,method)
			}
		})
	  },
	  //回退
	  handleManageBack(str){
          if(this.model.status===2){
             this.manageBack = '/mes-manufacture/mfProcessRouteMaintenance/back/' //工艺维护
		  }else if(this.model.status===3){
             this.manageBack = '/mes-manufacture/mfSuggest/back/' //建议
		  }else if(this.model.status===4){
             this.manageBack = '/mes-manufacture/mfSuggest/purchase/back/' //采购
		  }else if(this.model.status===5){
             this.manageBack = '/mes-manufacture/mfScientific/back/' //生管
		  }
		getAction(this.manageBack+this.model.id).then(res=>{
			this.$emit('ok')
			this.close()
		})
	  },
      //提交、保存
	  modalFrom(url,params,method){
         httpAction(url,params,method).then(res=>{
			 if(res.code === 0){
				 this.confirmLoading = false;
				 this.$emit('ok')
				 this.close()
			 } 
		 })
	  },
		handleOk (isSumit) {
			const that = this;
			// 触发表单验证
			this.form.validateFields((err, values) => {
			  if (!err) {
				  that.confirmLoading = true;
				  let httpurl = '';
				  let method = '';
				  console.log(this.model)
				  console.log(values)
				  let formData = Object.assign(this.model, values);
				  this.formData = Object.assign(this.model, values);
				  if(formData.scientificType ==='1'){
                     if(!formData.researchBom){
						 that.confirmLoading = false;
                       return this.$message.warning("请上传科研bom表")
					 }
					 if(!formData.bomReport){
						  that.confirmLoading = false;
                       return this.$message.warning("请上传BOMreport")
					 }
				  }else{
					  if(!formData.researchBom){
						  that.confirmLoading = false;
                       return this.$message.warning("请上传科研bom表")
					 }
				  }
               ////上传的
				if(formData.bomReport){
					const info = JSON.parse(formData.bomReport)
					if(info.length){
						formData.reportName = info[0].fileName || ''
						formData.bomReport=info[0].fileUrl || ''
					}
				}
				if(formData.researchBom){
					const info = JSON.parse(formData.researchBom)
					if(info.length){
						formData.researchName = info[0].fileName || ''
						formData.researchBom=info[0].fileUrl || ''
					}
				}
				if(formData.accessory){
					const info = JSON.parse(formData.accessory)
					if(info.length){
						formData.accessoryName = info[0].fileName || ''
						formData.accessory=info[0].fileUrl || ''
					}
				}	  
				  //新增触发
				  if(isSumit===1){
					httpurl+=this.url.add;
					method = 'post';
					if(this.EnhanceJS.afterAdd){
					  //新增之前
					  let Obj = eval(this.EnhanceJS.afterAdd)
					  new Obj(this)
					}else{
					  console.log("表单提交数据",formData)
					  formData.scientificPlease = this.userInfos.name //申请人
					//   formData.dptname = this.userInfo.orgposRemark //部门
					//   formData.dptno = this.userInfo.orgposRemark //部门
					  that.modalFrom(httpurl,formData,method)
					}
				  }else{
					//编辑触发
					httpurl+=this.url.edit;
					method = 'post';
					if(this.EnhanceJS.afterEdit){
					 //编辑之前
					  let Obj = eval(this.EnhanceJS.afterEdit)
					  new Obj(this)
					}else{
					  formData.scientificPlease = this.userInfos.name //申请人
					//   formData.dptname = this.userInfo.orgposRemark //部门
					//   formData.dptno = this.userInfo.orgposRemark //部门
					  console.log("表单提交数据",formData)
					  that.modalFrom(httpurl,formData,method)
					}
				  }
			   }
			})
		},
        //确认
		businessConfirm(){
            const that = this;
			this.form.validateFields((err, values) => {
			  if (!err) {
				  that.confirmLoading = true;
				  let httpurl = '';
				  let method = '';
				  let formData = Object.assign(this.model, values);
				  this.formData = Object.assign(this.model, values);
				  if(this.model.status===2){ //工艺路线维护
                    httpurl = this.url.routestr;
					method = 'get';
					that.modalFrom(httpurl+formData.id,method)
				  }else if(this.model.status===3){ //外协厂家范围
                    httpurl = this.url.approveSupplier;
					method = 'post';
					that.modalFrom(httpurl,this.supplierInfo,method)
				  }else if(this.model.status===4){ //采购确认
				    const info = {
						mesMfScientificId:formData.id,
						suggestEditParamList:[{id:this.radioInfo.id,supno:this.radioInfo.supno,status:1}]
					}
                    httpurl = this.url.procurement;
					method = 'put';
					that.modalFrom(httpurl,info,method)
				  }else if(this.model.status===6){ //事业部确认
				  const info = {
						actualCompletion: "",
						actualFinishTime: "",
						actualStartTime: "",
						id: 0,
						scientificCompleteTime: ""
					}
                    httpurl = this.url.businessConfirm;
					method = 'put';
					that.modalFrom(httpurl,formData,method)
				  }
				  
			  }

			})

		},

      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'scientificOrder','scientificPlease','dptname','scientificContact','scientificno','scientificname','scientificClassification','scientificType','name','contentTime','model','scientificStarttime','scientificQitime','scientificState','bomReport','researchBom','accessory','supno','supname','scientificCompleteTime','actualStartTime','actualFinishTime','actualCompletion','createBy','createTime','updateBy','updateTime'))
      },

      
    }
  }
</script>

<style lang="less" scoped>
.base-info{
	width: 100%;
	background-color: #E8E8E8;
	padding:5px 10px;
	margin-bottom: 10px;
	
}
.base-info-supplier{
		border: 1px solid rgb(170, 166, 166);
		width: 300px;
		height: 100px;
		padding:0 5px;
		margin: 10px 0;
		overflow-y: scroll;
	}
	.dtName{
		width: 200px;
		display: inline-block;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: nowrap;
	}
</style>
